﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlatRedBall.Graphics;
using FlatRedBall.Input;
using FlatRedBall;
using FlatRedBall.Math.Geometry;



namespace TopDownShooter.Screens
{
    public class TitleScreen : Screen
    {
        public TitleScreen()
            : base("TitleScreen")
        { }

        Text title;
        Text help;
        Text start;
        AxisAlignedRectangle helpBounds;
        AxisAlignedRectangle startBounds;
        public override void Initialize()
        {
            // Set the screen up here instead of in the Constructor to avoid
            // exceptions occurring during the constructor.
            FlatRedBallServices.Game.IsMouseVisible = true;

            base.Initialize();
            title = TextManager.AddText("Top Down Shooter");
            help = TextManager.AddText("Help");
            start = TextManager.AddText("Start (Space)");

            helpBounds = ShapeManager.AddAxisAlignedRectangle();
            startBounds = ShapeManager.AddAxisAlignedRectangle();

            mTexts.Add(title);
            mTexts.Add(help);
            mTexts.Add(start);
            mAxisAlignedRectangles.Add(helpBounds);
            mAxisAlignedRectangles.Add(startBounds);

            help.Scale = help.Spacing = 4;
            title.Scale = title.Spacing = 5;
            start.Scale = start.Spacing = 4;
            
            

            title.X = -30;
            title.Y = 30;

            help.Y = 0;
            help.X = -37;
            start.X = -37;
            start.Y = -20;

            helpBounds.X = -30;
            startBounds.X = -18;
            startBounds.Y = -20;
            startBounds.ScaleX = helpBounds.ScaleX = 8;
            startBounds.ScaleX = 20;
            startBounds.ScaleY = helpBounds.ScaleY = 3;

            startBounds.Visible = helpBounds.Visible = false;


            SpriteManager.Cameras.Clear();
            SpriteManager.Cameras.Add(new Camera(FlatRedBallServices.GlobalContentManager));
            SpriteManager.Camera.X = 0;
            SpriteManager.Camera.Y = 0;
            SpriteManager.Camera.Z = 100;
        }

        public override void Activity(bool firstTimeCalled)
        {
            if (InputManager.Mouse.IsOn(helpBounds))
            {
                help.SetColor(1, 1, 0);
                if (InputManager.Mouse.ButtonPushed(Mouse.MouseButtons.LeftButton))
                {
                    MoveToScreen(typeof(HelpScreen).FullName);
                }
            }
            else
            {
                help.SetColor(1, 1, 1);
            }
            if (InputManager.Mouse.IsOn(startBounds))
            {
                start.SetColor(1, 1, 0);
                if (InputManager.Mouse.ButtonPushed(Mouse.MouseButtons.LeftButton))
                {
                    FlatRedBallServices.Game.IsMouseVisible = false;
                    MoveToScreen(typeof(GameScreen).FullName);
                }
            }
            else
            {
                start.SetColor(1, 1, 1);
            }
            if (InputManager.Keyboard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Space))
            {
                FlatRedBallServices.Game.IsMouseVisible = false;
                MoveToScreen(typeof(GameScreen).FullName);
            }
            base.Activity(firstTimeCalled);
        }

        public override void Destroy()
        {
            base.Destroy();
        }
    }
}
